Hi Toby,
I've attached the routine in KMotion.exe that does the Flash New Version.
HTH Regards TK
Group: DynoMotion |
Message: 7345 |
From: fireup_kev |
Date: 4/27/2013 |
Subject: Re: Flashing firmware from application |
Thanks Tom,
I modified my V4.31c to have .NET access for LoadCoff to have 3 arguments.. I attached the 4 files in V4.31c folder.
Kevin
--- In DynoMotion@yahoogroups.com, Tom Kerekes <tk@...> wrote:
>
> Hi Toby,
>
> I've attached the routine in KMotion.exe that does the Flash New Version.
>
> HTH
> Regards
> TK
>
>
>
> ________________________________
> From: Toby Rule <trule@...>
> To: "DynoMotion@yahoogroups.com" <DynoMotion@yahoogroups.com>
> Sent: Thursday, April 25, 2013 6:11 AM
> Subject: [DynoMotion] Flashing firmware from application
>
>
>
> Â
> Hi Tom,
> Â
> Is there a way to programmatically flash the KFLOP firmware from a .NET application? Can you point me to an example? Even if you could give me a C++ snippet I could translate to C#.Â
> Â
> It looks like there are console commands for doing this, but Iâm not sure how they should be combined to load and flash a firmware image.
> Â
> When I distribute a new version of our application, which is based on a new version of the KMotion libraries, I want the application to automatically check for the firmware version, and if it is different than what is required by the new libraries, prompt the user to flash the firmware, which will be accomplished within the application.
> Â
> Thanks,
> Â
> Toby
> The information contained in this transmission is intended only for the person or entity
> to which it is addressed and may contain II-VI Proprietary and/or II-VI Business Sensitive
> material. If you are not the intended recipient, please contact the sender immediately
> and destroy the material in its entirety, whether electronic or hard copy. You are
> notified that any review, retransmission, copying, disclosure, dissemination or other
> use of, or taking of any action in reliance upon this information by persons or entities
> other than the intended recipient is prohibited.
>
|
|
Group: DynoMotion |
Message: 7352 |
From: Tom Kerekes |
Date: 4/28/2013 |
Subject: Re: Flashing firmware from application |
Hi Kevin,
It is included in the code base.
Thanks.
TK
Group: DynoMotion |
Message: 7359 |
From: fireup_kev |
Date: 4/28/2013 |
Subject: Re: Flashing firmware from application |
Tom,
What I mean to say was the current code base for C# does not offer a function for LoadCoff with 3 arguments to allow me to send a command like LoadCoff(-1, fileName, 1); I had to modify the source...
--- In DynoMotion@yahoogroups.com, Tom Kerekes <tk@...> wrote:
>
> Hi Kevin,
>
> It is included in the code base.Â
>
>
> Thanks.
>
> TK
>
>
>
> ________________________________
> From: fireup_kev <kliboon@...>
> To: DynoMotion@yahoogroups.com
> Sent: Saturday, April 27, 2013 6:57 PM
> Subject: [DynoMotion] Re: Flashing firmware from application
>
>
>
> Â
> Thanks Tom,
>
> I modified my V4.31c to have .NET access for LoadCoff to have 3 arguments.. I attached the 4 files in V4.31c folder.
>
> Kevin
>
> --- In DynoMotion@yahoogroups.com, Tom Kerekes <tk@> wrote:
> >
> > Hi Toby,
> >
> > I've attached the routine in KMotion.exe that does the Flash New Version.
> >
> > HTH
> > Regards
> > TK
> >
> >
> >
> > ________________________________
> > From: Toby Rule <trule@>
> > To: "DynoMotion@yahoogroups.com" <DynoMotion@yahoogroups.com>
> > Sent: Thursday, April 25, 2013 6:11 AM
> > Subject: [DynoMotion] Flashing firmware from application
> >
> >
> >
> > ÃÂ
> > Hi Tom,
> > ÃÂ
> > Is there a way to programmatically flash the KFLOP firmware from a .NET application?ÃÂ Can you point me to an example?ÃÂ Even if you could give me a C++ snippet I could translate to C#.ÃÂ
> > ÃÂ
> > It looks like there are console commands for doing this, but Iââ¬â¢m not sure how they should be combined to load and flash a firmware image.
> > ÃÂ
> > When I distribute a new version of our application, which is based on a new version of the KMotion libraries, I want the application to automatically check for the firmware version, and if it is different than what is required by the new libraries, prompt the user to flash the firmware, which will be accomplished within the application.
> > ÃÂ
> > Thanks,
> > ÃÂ
> > Toby
> > The information contained in this transmission is intended only for the person or entity
> > to which it is addressed and may contain II-VI Proprietary and/or II-VI Business Sensitive
> > material. If you are not the intended recipient, please contact the sender immediately
> > and destroy the material in its entirety, whether electronic or hard copy. You are
> > notified that any review, retransmission, copying, disclosure, dissemination or other
> > use of, or taking of any action in reliance upon this information by persons or entities
> > other than the intended recipient is prohibited.
> >
>
|
|
Group: DynoMotion |
Message: 7360 |
From: Tom Kerekes |
Date: 4/28/2013 |
Subject: Re: Flashing firmware from application |
Hi Kevin,
Yes, I meant to say your changes have been incorporated into our code so they will be in the next release.
Thanks TK
Group: DynoMotion |
Message: 7387 |
From: Toby Rule |
Date: 4/30/2013 |
Subject: Re: Flashing firmware from application |
Can I get a copy of this patch? Is this folder publically accessible? It would be nice not having to write the interface code myself…
Thanks,
Toby
Group: DynoMotion |
Message: 7389 |
From: Tom Kerekes |
Date: 4/30/2013 |
Subject: Re: Flashing firmware from application |
Hi Toby, Kevin put them here: http://tech.groups.yahoo.com/group/DynoMotion/files/V4.31c/ The additions will be in the next release. Regards TK
Group: DynoMotion |
Message: 7393 |
From: Toby Rule |
Date: 5/1/2013 |
Subject: Re: Flashing firmware from application [1 Attachment] |
Hi Tom,
After looking at the code, there is one thing I don’t understand. after sending the “ProgFlashImage” command, it looks like waitDlg is waiting for the board
state to change, indicating success or failure. What board state is it waiting for, to indicate success or failure?
Thanks,
Toby
Group: DynoMotion |
Message: 7394 |
From: Tom Kerekes |
Date: 5/1/2013 |
Subject: Re: Flashing firmware from application |
Hi Toby,
ProgFlashImage operates differently than most all other commands. It Blocks all KFLOP communication until it is finished and comes back with either the "Ready" response or some type of Error message. I've attached the code that KMotion.exe uses which makes use of the "CheckReady" library call.
HTH Regards TK
Group: DynoMotion |
Message: 11678 |
From: geraldft |
Date: 6/11/2015 |
Subject: Re: Flashing firmware from application |
Hi Tom Is there any way to access these operations from VB ? I am also looking at making a little program to upgrade boards. I can see some console commands related to flashing such as ClearFlashImage ProgFlashImage Flash and LoadFlash
but it's not immediately clear if these can be used for flashing a new version, seems maybe they are only for C threads and persist user data?
Thanks Gerald
|
|
Group: DynoMotion |
Message: 11738 |
From: Tom Kerekes |
Date: 6/21/2015 |
Subject: Re: Flashing firmware from application |
Hi Gerald,
Are you still interested in this?
It is fairly simple to Flash "New Version" from an App. Use the LoadCoff Library command with the special PackToFlash Option set. This packs all the various memory segments, boot loader, etc into the SDRAM Memory in KFLOP
int CKMotionDLL::LoadCoff(int Thread, const char *Name, int PackToFlash)
Thead = -1 Name = full filename of KFLOP .out file
PackToFlash = 1
Then send the Console Command "ProgFlashImage"
To flash User Data and User Programs to KFLOP first set any Launch on Startup options with the Console Command "SetStartupThread x 1" then send the "Flash" command to Flash all memory.
HTH Regards TK
Group: DynoMotion |
Message: 11739 |
From: geraldft |
Date: 6/22/2015 |
Subject: Re: Flashing firmware from application |
Hi Tom
I am interested still. But I don't understand how to set the LoadCoff command. It's not a console command. Can I use it from a vb app?
Thanks Gerald
|
|
Group: DynoMotion |
Message: 11740 |
From: geraldft |
Date: 6/22/2015 |
Subject: Re: Flashing firmware from application |
Meanwhile - I did find a clue about this - but I think there might be a problem with the KM_VBLink file - it's not been updated for a while and doesn't include all the options you mention...
ie it reads :
Private Declare Function KMViaVB_LoadCoff Lib "KMViaVB" (ByVal handle As Long, ByVal Thread As Short, ByVal Name As String) As Integer
then :
Public Function KM_LoadCoff(ByVal Thread As Integer, ByVal Name As String) As Integer If global_KM_Handle = 0 Then KM_Open() If global_KM_Handle = 0 Then KM_LoadCoff = 13 Exit Function End If End If KM_LoadCoff = KMViaVB_LoadCoff(global_KM_Handle, Thread, Name) End Function
|
|
Group: DynoMotion |
Message: 11742 |
From: Tom Kerekes |
Date: 6/22/2015 |
Subject: Re: Flashing firmware from application |
Hi Gerald,
Yes the KMViaVB interface doesn't pass that parameter you would need to add it.
Why not use the .NET interface instead?
Regards TK
Group: DynoMotion |
Message: 11753 |
From: geraldft |
Date: 6/23/2015 |
Subject: Re: Flashing firmware from application |
Thanks for the suggestion, but to this day I have not been able to even run the VB.net example. Hence I prefer to use the established methods I know and
mostly understand... :)
Meantime I took a stab at changing the VBLink file - it
looks like this now :
Private Declare Function KMViaVB_LoadCoff
Lib "KMViaVB" (ByVal handle As Long, ByVal Thread As Short, ByVal Name
As String, ByVal PackToFlash As Integer) As Integer
Public Function KM_LoadCoff(ByVal Thread As Integer, ByVal Name As String, ByVal PackToFlash As Integer) As Integer If global_KM_Handle = 0 Then KM_Open() If global_KM_Handle = 0 Then KM_LoadCoff = 13 Exit Function End If End If KM_LoadCoff = KMViaVB_LoadCoff(global_KM_Handle, Thread, Name, PackToFlash) End Function
Is
it correct this is all I need to do? I then wrote an implementation
but I seem to be getting an error. This is my vb code :
Dim Name As String = MainPath & "\DSPKFLOP.out" ' Note - "Mainpath" is the working directory
If My.Computer.FileSystem.FileExists(Name) = False Then MsgBox("File not found.") Exit Sub End If
Dim rtrn As Integer = KM_LoadCoff(-1, Name, 1)
If rtrn > 0 Then MsgBox("Failed To Initiate - Error = " & rtrn) Else FlashBtn.Visible = True FlashBtnLbl.Visible = True End If
It returns '1' which indicates an error? I have not dared to proceed further until this is clarified.
|
|
Group: DynoMotion |
Message: 11758 |
From: Tom Kerekes |
Date: 6/23/2015 |
Subject: Re: Flashing firmware from application |
Hi Gerald,
You would also need to change KMviaVB.cpp/.h to handle the passed parameter. Change:
long __stdcall KMViaVB_LoadCoff(void *handle,long Thread, char *Name) { CKMotionDLL *KM_dll=(CKMotionDLL *)handle; long rslt=KM_dll->LoadCoff(Thread,Name,false); return rslt; }
to:
long __stdcall KMViaVB_LoadCoff(void *handle,long Thread, char *Name, long PackToFlash) { CKMotionDLL *KM_dll=(CKMotionDLL *)handle; long rslt=KM_dll->LoadCoff(Thread,Name,PackToFlash); return rslt; }
HTH Regards TK
Group: DynoMotion |
Message: 11763 |
From: geraldft |
Date: 6/24/2015 |
Subject: Re: Flashing firmware from application |
Hi Tom I rebuilt the BuildAllLibs and updated two files in my application KMViaVB.dll and the KmotionDLL.dll Here is a summary of the changes to date, but it still returns an error. KMViaVB.cpp long __stdcall KMViaVB_LoadCoff(long *handle,long Thread, char *Name, long PackToFlash) { CKMotionDLL *KM_dll=(CKMotionDLL *)handle; long rslt=KM_dll->LoadCoff(Thread,Name,PackToFlash); return rslt; } KMViaVB.h long __stdcall KMViaVB_LoadCoff(long *handle, long Thread, char *Name, long PackToFlash); KM_VBLink.vb Private Declare Function KMViaVB_LoadCoff Lib "KMViaVB" (ByVal handle As Long, ByVal Thread As Integer, ByVal Name As String, ByVal PackToFlash As Integer) As Integer Public Function KM_LoadCoff(ByVal Thread As Integer, ByVal Name As String, ByVal PackToFlash As Integer) As Integer If global_KM_Handle = 0 Then KM_Open() If global_KM_Handle = 0 Then KM_LoadCoff = 13 Exit Function End If End If KM_LoadCoff = KMViaVB_LoadCoff(global_KM_Handle, Thread, Name, PackToFlash) End Function Thanks Gerald ---In DynoMotion@yahoogroups.com, <tk@...> wrote : Hi Gerald,
You would also need to change KMviaVB.cpp/.h to handle the passed parameter. Change:
long __stdcall KMViaVB_LoadCoff(void *handle,long Thread, char *Name) { CKMotionDLL *KM_dll=(CKMotionDLL *)handle; long rslt=KM_dll->LoadCoff(Thread,Name,false); return rslt; }
to:
long __stdcall KMViaVB_LoadCoff(void *handle,long Thread, char *Name, long PackToFlash) { CKMotionDLL *KM_dll=(CKMotionDLL *)handle; long rslt=KM_dll->LoadCoff(Thread,Name,PackToFlash); return rslt; }
HTH Regards TK
Group: DynoMotion |
Message: 11778 |
From: geraldft |
Date: 6/25/2015 |
Subject: Re: Flashing firmware from application |
Hi Tom - I am still trying to resolve this. I have
attempted some detective work and modified the KMotionDLL.cpp code in
the hope of finding where the error is happening.
I get return =
2 now,
so the error is returned on the first line : if(Thread==0) ie my
input value of "-1" has been turned in to a "0" So I hope this will
provide enough clues why this is not working?
int CKMotionDLL::LoadCoff(int Thread, const char *Name, int PackToFlash) { CString s; unsigned int EntryPoint;
if (Thread==0) return 2;
if (PackToFlash==0 && CheckKMotionVersion()) return 3;
if (PackToFlash==0) { s.Format("Kill %d", Thread); // make sure the Thread isn't running if (WriteLine(s)) return 4; }
|
|
Group: DynoMotion |
Message: 11779 |
From: Tom Kerekes |
Date: 6/25/2015 |
Subject: Re: Flashing firmware from application |
Hi Gerald,
I was able to get it to work. I suspect your issue is with the Long/short/Integer mixups.
I changed the Jogger example to Check for Thread = -1 as a Key to flash a .out file.
Here is the success (running Version 4.33i and Flashing 4.33f):
Here is the new code in "Compile Load Coff"
Private Sub CompileLoadCoff_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CompileLoadCoff.Click Dim Err As String = "Bad File" Dim result As Integer
If CThread.Text = -1 Then result = KM_LoadCoff(CThread.Text, CFile.Text, 1) If (result = 0) Then result = KM_WriteLineWithEcho("ProgFlashImage") End If Do result = KM_CheckForReady(0) Loop While (result <> 2) result = 0 Else result = KM_CompileAndLoadCoff(CThread.Text, CFile.Text, Err, 250) End If
If (result = 0) Then CompilerOutput.Text = "No Errors" Else CompilerOutput.Text = Err End If End Sub
I'll attach the changed files:
HTH Regards TK
Group: DynoMotion |
Message: 11838 |
From: geraldft |
Date: 7/1/2015 |
Subject: Re: Flashing firmware from application |
Correct - the problem was the code in VBLink.vb
You had :
KMViaVB_LoadCoff Lib "KMViaVB" (ByVal handle As Long
when it should have been "Integer"....
I'm not sure why there is the disparity between Integer and Long in the various files...?
But now the error has disappeared.... so now moving on to complete the rest... :)
|
|
| | | | | | | | | | | | | | | | | | | | | | | |